﻿using System;
using System.Windows;
using System.Windows.Media;

namespace Gmantis.Controls
{
    public class ClearStyleExtensions : DependencyObject
    {
        // Fields
        public static readonly DependencyProperty ButtonBackgroundProperty = DependencyProperty.RegisterAttached("ButtonBackground", typeof(Brush), typeof(ClearStyleExtensions), new PropertyMetadata(null));
        public static readonly DependencyProperty ButtonForegroundProperty = DependencyProperty.RegisterAttached("ButtonForeground", typeof(Brush), typeof(ClearStyleExtensions), new PropertyMetadata(null));
        public static readonly DependencyProperty CaretBrushProperty = DependencyProperty.RegisterAttached("CaretBrush", typeof(Brush), typeof(ClearStyleExtensions), new PropertyMetadata(null));
        public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.RegisterAttached("CornerRadius", typeof(CornerRadius), typeof(ClearStyleExtensions), new PropertyMetadata(new CornerRadius()));
        public static readonly DependencyProperty FocusBrushProperty = DependencyProperty.RegisterAttached("FocusBrush", typeof(Brush), typeof(ClearStyleExtensions), new PropertyMetadata(null));
        public static readonly DependencyProperty MouseOverBrushProperty = DependencyProperty.RegisterAttached("MouseOverBrush", typeof(Brush), typeof(ClearStyleExtensions), new PropertyMetadata(null));
        public static readonly DependencyProperty PressedBrushProperty = DependencyProperty.RegisterAttached("PressedBrush", typeof(Brush), typeof(ClearStyleExtensions), new PropertyMetadata(null));
        public static readonly DependencyProperty ScrollBarStyleProperty = DependencyProperty.RegisterAttached("ScrollBarStyle", typeof(Style), typeof(ClearStyleExtensions), new PropertyMetadata(null));

        // Methods
        public static Brush GetButtonBackground(FrameworkElement element)
        {
            return (element.GetValue(ButtonBackgroundProperty) as Brush);
        }

        public static Brush GetButtonForeground(FrameworkElement element)
        {
            return (element.GetValue(ButtonForegroundProperty) as Brush);
        }

        public static Brush GetCaretBrush(FrameworkElement element)
        {
            return (element.GetValue(CaretBrushProperty) as Brush);
        }

        public static CornerRadius GetCornerRadius(FrameworkElement element)
        {
            return (CornerRadius)element.GetValue(CornerRadiusProperty);
        }

        public static Brush GetFocusBrush(FrameworkElement element)
        {
            return (element.GetValue(FocusBrushProperty) as Brush);
        }

        public static Brush GetMouseOverBrush(FrameworkElement element)
        {
            return (element.GetValue(MouseOverBrushProperty) as Brush);
        }

        public static Brush GetPressedBrush(FrameworkElement element)
        {
            return (element.GetValue(PressedBrushProperty) as Brush);
        }

        public static Style GetScrollBarStyle(FrameworkElement element)
        {
            return (Style)element.GetValue(ScrollBarStyleProperty);
        }

        public static void SetButtonBackground(FrameworkElement element, Brush value)
        {
            if ((element != null) && (value != null))
            {
                element.SetValue(ButtonBackgroundProperty, value);
            }
        }

        public static void SetButtonForeground(FrameworkElement element, Brush value)
        {
            if ((element != null) && (value != null))
            {
                element.SetValue(ButtonForegroundProperty, value);
            }
        }

        public static void SetCaretBrush(FrameworkElement element, Brush value)
        {
            if ((element != null) && (value != null))
            {
                element.SetValue(CaretBrushProperty, value);
            }
        }

        public static void SetCornerRadius(FrameworkElement element, CornerRadius value)
        {
            if (element != null)
            {
                element.SetValue(CornerRadiusProperty, value);
            }
        }

        public static void SetFocusBrush(FrameworkElement element, Brush value)
        {
            if ((element != null) && (value != null))
            {
                element.SetValue(FocusBrushProperty, value);
            }
        }

        public static void SetMouseOverBrush(FrameworkElement element, Brush value)
        {
            if ((element != null) && (value != null))
            {
                element.SetValue(MouseOverBrushProperty, value);
            }
        }

        public static void SetPressedBrush(FrameworkElement element, Brush value)
        {
            if ((element != null) && (value != null))
            {
                element.SetValue(PressedBrushProperty, value);
            }
        }

        public static void SetScrollBarStyle(FrameworkElement element, Style value)
        {
            if ((element != null) && (value != null))
            {
                element.SetValue(ScrollBarStyleProperty, value);
            }
        }
    }
}
